import { drawEllipse } from "replicad";
import { drawRoundedRectangle } from "replicad";

// The replicad code! Not much there!
export function drawBox(thickness) {
  const rect = drawRoundedRectangle(30, 50);// 画笔

  const skech = rect.sketchOnPlane() // 草图
    const shape = skech.extrude(20, {}) // shape solid 这里挤出之后是一个立方体，也就是说前面的rect是面  
    // Hollows out the current shape, removing the faces found by the filter and keeping a border of thickness
    // 中空当前形状，移除过滤器找到的面，并加厚度
    // 这里就是找到xy平面，20表示的是 距离原点20 ，当然他的实现方式比three要繁琐很多
    const mesh = shape.shell(thickness, (f) => f.inPlane("XY", 20));
    console.log(rect,skech,shape,mesh )
    /**
     * shape 下面有face 和edge  face 是面 edge是边 一个面由多个三角面组成，同理一条边，由多线段组成。
     */
    return mesh;
}

export function drawElipse() {
  const start = performance.now();
  const ellipse = drawEllipse(30, 50);
  const skech = ellipse.sketchOnPlane();
  const shape = skech.extrude(20, {});
  const shape2 = shape.fillet(2)  
  const end = performance.now();
  console.log(`Fillet took ${end - start} milliseconds.`);
  // const mesh = shape.shell(5, (f) => f.inPlane("XY", 20));
  return shape2;
}